package com.tansuo365.test1.controller.othercontrol;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tansuo365.test1.bean.otherbean.ShengouZhixing;
import com.tansuo365.test1.service.otherservice.ShengouZhixingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("/admin/shengouzhixing")
@RestController
public class ShengouZhixingController {
    @Autowired
    private ShengouZhixingService shengouZhixingService;

    @RequestMapping("/getSelective")
    public Map<String, Object> getZhixing(ShengouZhixing shengouZhixing, @RequestParam(value = "page", required = true) Integer page, @RequestParam(value = "rows", required = true) Integer rows) {
        if (shengouZhixing == null) {
            return null;
        }
        Map<String, Object> resultMap = new HashMap<>();
        PageHelper.startPage(page, rows);
        List<ShengouZhixing> shengouzhixingList = shengouZhixingService.listShengouZhixingSelective(shengouZhixing);
        PageInfo<ShengouZhixing> pageInfo = new PageInfo<ShengouZhixing>(shengouzhixingList);
        resultMap.put("rows", pageInfo.getList());
        resultMap.put("total", pageInfo.getTotal());
        return resultMap;
    }

}
